/*
 * @Author: C.
 * @Date: 2023-03-14 14:58:07
 */
import { onMounted } from 'vue';
import { FormProps } from '/@/components/Form';
import { useModal, UseModalReturnType } from '/@/components/Modal';
import type { DynamicProps } from '/#/utils';

type Props = Partial<DynamicProps<FormProps>>;

export function useFormModel(props?: Props): UseModalReturnType {
  const [registerModal, modelAction] = useModal();
  onMounted(() => {
    modelAction.openModal(false, {
      init: true,
      labelWidth: 100,
      baseColProps: { span: 24 },
      schemas: [],
      showActionButtonGroup: false,
      actionColOptions: {
        span: 23,
      },
      ...props,
    });
  });
  return [registerModal, modelAction];
}
